<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 5.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--common-->
<link href="${pageContext.request.contextPath }/admin/css/style.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath }/admin/css/style-responsive.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath }/admin/css/stuInfoManage/main.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath }/admin/css/stuInfoManage/stuInfoManage.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath }/admin/css/stuInfoManage/stuInfoSearch.css"
	rel="stylesheet">
<script
	src="${pageContext.request.contextPath }/admin/js/jquery-1.10.2.min.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
	function userInfo(uId) {
		var url = "${pageContext.request.contextPath }/admin/userInfoSelect.do";
		$
				.ajax({
					type : "post",
					url : url,
					dataType : 'json',
					data : {
						uId : uId,
					},
					success : function(result) {
						var dataObj = result; //返回的result为json格式的数据
						console.log(dataObj);
						var datas = "";
						$
								.each(
										dataObj,
										function(index, user) {
											datas += "<tr class='success'>";
											datas += "<td>" + user.uName
													+ "</td>";
											datas += "<td>" + user.uCId
													+ "</td>";
											datas += "<td>" + user.uTelphone
													+ "</td>";
											datas += "<td>" + user.uCardid
													+ "</td>";
											datas += "<td>" + user.uAddress
													+ "</td>";
											datas += "<td>" + user.uEmail
													+ "</td>";
											datas += "<td>" + user.uState
													+ "</td>";
											datas += "<td><button type='button' class='btn btn-warning' onclick=\"updateState('"
													+ user.uId
													+ "')\">冻结</button></td>";
											datas += "</tr>";
										});
						$("#userInfoList").html(datas);//要刷新的div
					},
					error : function() {
						alert("失败");
					}
				});
	}
	
	function selectUser() {
		var uName = $("#uName").val();
		var url = "${pageContext.request.contextPath }/admin/selectByName.do";
		$
				.ajax({
					type : "post",
					url : url,
					dataType : 'json',
					data : {
						uName : uName
					},
					success : function(result) {
						var dataObj = result; //返回的result为json格式的数据
						console.log(dataObj);
						var datas = "";
						$
								.each(
										dataObj,
										function(index, user) {
											if (index % 2 == 0)
												datas += "<tr class='success'>";
											else
												datas += "<tr class='info'>";
											datas += "<td>" + user.uName
													+ "</td>";
											datas += "<td>" + user.uCId
													+ "</td>";
											datas += "<td><button type='button' class='btn btn-info' onclick=\"userInfo('"
													+ user.uId
													+ "')\">详细信息</button></td>";
											datas += "</tr>";
										});
						$("#userInfoList").html(datas);//要刷新的div
					},
					error : function() {
						alert("失败");
					}
				});
	}

	function updateState(uId) {
		var url = "${pageContext.request.contextPath }/admin/freezeUser.do";
		$.ajax({
			type : "post",
			url : url,
			dataType : 'json',
			data:{uId:uId},
			success : function(result) {
				getUserInfo(1);
			},
			error : function() {
				getUserInfo(1);
			}
		});
	}

	function getUserInfo(page) {
		var url = "${pageContext.request.contextPath }/admin/userInfoSelect.do";
		$
				.ajax({
					type : "post",
					url : url,
					dataType : 'json',
					data:{page:page},
					success : function(result) {
						var dataObj = result; //返回的result为json格式的数据
						console.log(dataObj);
						var datas = "";
						$
								.each(
										dataObj,
										function(index, user) {
											if (index % 2 == 0)
												datas += "<tr class='success'>";
											else
												datas += "<tr class='info'>";
											datas += "<td>" + user.uName
													+ "</td>";
											datas += "<td>" + user.uCId
													+ "</td>";
											datas += "<td>" + user.uTelphone
													+ "</td>";
											datas += "<td>" + user.uCardid
													+ "</td>";
											datas += "<td>" + user.uAddress
													+ "</td>";
											datas += "<td>" + user.uEmail
													+ "</td>";
											datas += "<td>" + user.uState
													+ "</td>";
											datas += "<td><button type='button' class='btn btn-warning' onclick=\"updateState('"
													+ user.uId
													+ "')\">冻结</button></td>";
											datas += "</tr>";
										});
						$("#userInfoList").html(datas);//要刷新的div
					},
					error : function() {
						alert("失败");
					}
				});
	}
</script>
</head>
<body class="sticky-header" onload="getUserInfo(1)">
	<section> <!-- 导入左边菜单栏 --> <%@include
		file="common/sidebarStart.jsp"%>
	<li class="menu-list nav-active"><a href="#"><i
			class="fa fa-book"></i> <span>用户信息管理</span></a>
		<ul class="sub-menu-list">
			<li><a
				href="${pageContext.request.contextPath }/page.do?url=admin/verify">
					用户信息审核</a></li>
			<li><a
				href="${pageContext.request.contextPath }/page.do?url=admin/userInfoSelect">
					用户信息查询</a></li>
		</ul></li>

	<li class="menu-list"><a href=""><i class="fa fa-tasks"></i> <span>反馈信息管理</span></a>
		<ul class="sub-menu-list">
			<li><a
				href="${pageContext.request.contextPath }/page.do?url=admin/selectFeedback">
					查看反馈信息</a></li>
		</ul></li>

	<li class="menu-list"><a href="#"><i class="fa fa-th-list"></i>
			<span>发布公告</span></a>
		<ul class="sub-menu-list">
			<li class="active"><a
				href="${pageContext.request.contextPath }/page.do?url=admin/sendNotice">
					网站发布公告 </a></li>
		</ul></li>
	<%@include file="common/sidebarEnd.jsp"%> <!-- 主内容开始-->
	<div class="main-content">
		<!-- 通知菜单栏 -->
		<%@include file="common/notifyMenu.jsp"%>

		<div class="container">
			<div class="row">
				<div class="col-md-4"></div>
				<div class="col-md-4 little-title">用户信息查询界面</div>
				<div class="col-md-3 stuInfoSearchForm">
					<!--查询开始-->
					<div class="input-group">
						<input type="text" id="uName" class="form-control"
							placeholder="输入用户姓名..."> <span class="input-group-btn">
							<button class="btn btn-default" type="button"
								onclick="selectUser()">搜索</button>
						</span>
					</div>
					</form>
					<!--查询结束-->
				</div>
				<div class="col-md-1"></div>
			</div>
			<div class="row">
				<div class="col-md-1"></div>
				<div class="stuInfo">
					<table class="table table-bordered table-hover">
						<thead>
							<tr class="danger">
								<th>用户名</th>
								<th>银行卡ID</th>
								<th>手机号码</th>
								<th>身份证号</th>
								<th>住址</th>
								<th>邮箱</th>
								<th>账号是否激活</th>
								<th>冻结用户</th>
							</tr>
						</thead>
						<tbody class="stuInfo2" id="userInfoList">

						</tbody>

					</table>
				</div>
				<div class="col-md-1"></div>
			</div>
			<div class="row" id="paging">
				<div class="col-md-4"></div>
				<div class="col-md-4">
					<nav aria-label="Page navigation">
					<ul class="pagination">
						<li><a href="#" aria-label="Previous"> <span
								aria-hidden="true">&laquo;</span>
						</a></li>
						<li><a
							onclick="getUserInfo(1)">1</a></li>
						<li><a
							onclick="getUserInfo(2)">2</a></li>
						<li><a
							onclick="getUserInfo(3)">3</a></li>
						<li><a
							onclick="getUserInfo(4)">4</a></li>
						<li><a
							onclick="getUserInfo(5)">5</a></li>
						<li><a
							onclick="getUserInfo(6)">6</a></li>
						<li><a href="#" aria-label="Next"> <span
								aria-hidden="true">&raquo;</span>
						</a></li>
					</ul>
					</nav>
				</div>
				<div class="col-md-4"></div>
			</div>
		</div>
	</div>
	<!-- 主内容结束--> </section>

	<!-- Placed js at the end of the document so the pages load faster -->
	<script
		src="${pageContext.request.contextPath }/admin/js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/admin/js/auto.js"></script>
	<script
		src="${pageContext.request.contextPath }/admin/js/jquery-ui-1.9.2.custom.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/admin/js/jquery-migrate-1.2.1.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/admin/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/admin/js/modernizr.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/admin/js/jquery.nicescroll.js"></script>

	<!--页面公共脚步-->
	<script src="${pageContext.request.contextPath }/admin/js/scripts.js"></script>

</body>
</html>